<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>更改字体颜色</title>
<script>
  function changeColor(event) {
    var c = event.target.style.color;
    var bgc = event.target.style.backgroundColor;
    if (c !== "white" && bgc !== "black") {
      c = "white";
      bgc = "black";
    } else {
      c = "black";
      bgc = "white";
    }
    event.target.style.color = c;
    event.target.style.backgroundColor = bgc;
  }
</script>
</head>
<body>
  <pre>
    <span onclick="changeColor(event)">第一行内容</span>
    <span onclick="changeColor(event)">第二行内容</span>
    <span onclick="changeColor(event)">第三行内容</span>
    <span onclick="changeColor(event)">第四行内容</span>
    <span onclick="changeColor(event)">第五行内容</span>
    <span onclick="changeColor(event)">第六行内容</span>
    <span>点击以上任意一个span元素内的文本以更改文本的样式</span>
</pre>
</body>
</html>
